<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script language="javaScript" type="text/javascript"
	src="<c:url value='/cal/calendar.js'/>" >
</script>

<link href="<c:url value='/cal/calendar.css'/>" rel="stylesheet" type="text/css">
<link href="<c:url value='/Styles/style.css'/>" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@page import="model.UserDTO"  %>
<%@page import="bizlogic.UserManager"  %>
<%@page import="java.util.*" %>
<%
       UserDTO user = (UserDTO)session.getAttribute("user");
  		
       if(user == null){
    	   response.sendRedirect("/LeaveApplication/welcome.jsp");
    	   System.out.print("coming 1");
       }
       else if(user.getPosition().getRole().equalsIgnoreCase("Admin")){
      	 	response.sendRedirect("/LeaveApplication/welcome.jsp");
      	 	System.out.print("coming 2");
       }
       else
       {
    	   UserManager um = new UserManager();
    	   ArrayList<UserDTO> listAll=um.findAllUser();
    	   ArrayList<String> anylist=new ArrayList<String>();
    	   ListIterator it = listAll.listIterator();
    	   as:while(it.hasNext())
    	   {
    		   UserDTO emp = (UserDTO)it.next();
    		   if(emp.getManager()!=null)
    	   		   	if(user.getManager() != null)
    	   		   	{
    					if(emp.getManager().getId().equalsIgnoreCase(user.getId()))
    					{
    						session.setAttribute("isManager","true");
    						break as;
    					}
    					else
    					{
    						session.setAttribute("isManager","false");
    						System.out.println("not manager");
    					}
    	   		   	}
    		  // System.out.print(emp.toString());
    	   }
    	   
       }
%>
</head>
<body>
					<p align="center"><%=user.getName() %></p><br/>
<table align="center">
					<c:if test="${isManager}">  <th>Management Panel<th> </c:if>
						<!-- Main Content -->
					<c:if test="${isManager=='true'}">
						<tr><td><a href="process">Process General Leave</a></td></tr>
						<tr><td><a href="processCompensation">Process Compensation Leave</a></td></tr>
						<tr><td><a href="ProcessCompensationClaim">Process Compensation Claim</a></td></tr>
						<tr><td><a href="SubordinateServlet">Subordinate Leave History</a></td></tr>
						<!-- manager menu here -->
					</c:if>
</table>						
<table  align="center">						
 					<th>Employee Panel</th>
 						<!-- staff menu here -->
 					 <tr><td><a href="SubmitLeaveServlet">Apply Leave</a></td></tr>
 					 <tr><td><a href="ViewLeaveApplicationByStaff">Personal Application Status</a></td></tr>
 					 <tr><td><a href="LoadLeaveHistoryServlet">Personal Leave History</a></td></tr>
 					 <tr><td><a href="LoadDataOTServlet">Claim Overtime</a></td></tr>
 					 <tr><td><a href="leaveeditview">Update Leave</a></td></tr>		
					 <!-- end col2 -->
</table>					
</body>
</html>